<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <ul>
            <li v-for="item in unCompleted" :key="item.id">
                {{item.todo}}
            </li>
        </ul>
    </div>
</body>

</html>
<script src='https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js'></script>
<script>
    //v-for v-if 这两条指令的优先级问题,vue2中 v-for的优先级要高于v-if
    //v-for和v-if永远不要放在同一个元素上(组件),会带来性能问题
    //需求:只展示completed为false的数据
    let vm = new Vue({
        el: '#app',
        data: {
            msg: "李雷",
            arr: [
                {
                    id: 1,
                    todo: '写代码',
                    completed: false
                },
                {
                    id: 2,
                    todo: '学vue',
                    completed: true
                },
                {
                    id: 3,
                    todo: '吃药',
                    completed: false
                },
            ]
        },
        computed: {
            unCompleted() {
                return this.arr.filter(item => item.completed === false)
            }
        }
    })
</script>